package com.qianfeng.libra.cowshop.app.tasks;

import android.os.AsyncTask;
import com.qianfeng.libra.cowshop.app.utils.HttpTools;
import org.json.JSONObject;

/**
 * Created by ligang on 2015/3/25.
 */
public class LoginUpTask extends AsyncTask<String, Integer, JSONObject> {
    private MyProcessor processor;

    public LoginUpTask(MyProcessor processor) {
        this.processor = processor;
    }

    @Override
    protected JSONObject doInBackground(String... strings) {
        JSONObject ret = null;
        if (strings != null && strings.length > 0) {
            String url = strings[0];
            byte[] bytes = HttpTools.get(url);
            if (bytes != null) {
                try {
                    String str = new String(bytes, "UTF-8");
                    ret = new JSONObject(str);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return ret;
    }

    @Override
    protected void onPostExecute(JSONObject jsonObject) {
        if (processor != null) {
            processor.myProcessResult(jsonObject);
        }

    }
}
